import { BaseController } from 'egg-cool-controller';
import router from 'egg-cool-router';
// import { Brackets } from 'typeorm';

@router.prefix('/api/plan', [ 'add', 'delete', 'update', 'info', 'list', 'page' ])
export default class Plan extends BaseController {
    init() {
        const _this = this;
        _this.setEntity(this.ctx.repo.Plan);
        _this.setPageOption({
            // where: new Brackets(qb => {
            //     const query = _this.getQuery();
            //     if (query.start && query.end) {
            //         qb.andWhere('createTime BETWEEN :start AND :end', {
            //             start: query.start,
            //             end: query.end,
            //         });
            //     }
            // }),
            addOrderBy: {
                // 查询plan需要按照 月 过滤
                createTime: 'desc',
            },
        });
        this.setService(this.service.plan);
    }
}
